/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package ms.jasim.model.impl;

import java.util.Collection;

import ms.jasim.model.Decomposition;
import ms.jasim.model.Goal;
import ms.jasim.model.ModelPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.EObjectResolvingEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Goal</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link ms.jasim.model.impl.GoalImpl#getDecomposition <em>Decomposition</em>}</li>
 *   <li>{@link ms.jasim.model.impl.GoalImpl#getPrecedence <em>Precedence</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class GoalImpl extends CustomizableObjectImpl implements Goal {
	/**
	 * The cached value of the '{@link #getDecomposition() <em>Decomposition</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDecomposition()
	 * @generated
	 * @ordered
	 */
	protected EList<Decomposition> decomposition;

	/**
	 * The cached value of the '{@link #getPrecedence() <em>Precedence</em>}' reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPrecedence()
	 * @generated
	 * @ordered
	 */
	protected EList<Goal> precedence;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected GoalImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return ModelPackage.Literals.GOAL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Decomposition> getDecomposition() {
		if (decomposition == null) {
			decomposition = new EObjectContainmentEList<Decomposition>(Decomposition.class, this, ModelPackage.GOAL__DECOMPOSITION);
		}
		return decomposition;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Goal> getPrecedence() {
		if (precedence == null) {
			precedence = new EObjectResolvingEList<Goal>(Goal.class, this, ModelPackage.GOAL__PRECEDENCE);
		}
		return precedence;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case ModelPackage.GOAL__DECOMPOSITION:
				return ((InternalEList<?>)getDecomposition()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case ModelPackage.GOAL__DECOMPOSITION:
				return getDecomposition();
			case ModelPackage.GOAL__PRECEDENCE:
				return getPrecedence();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case ModelPackage.GOAL__DECOMPOSITION:
				getDecomposition().clear();
				getDecomposition().addAll((Collection<? extends Decomposition>)newValue);
				return;
			case ModelPackage.GOAL__PRECEDENCE:
				getPrecedence().clear();
				getPrecedence().addAll((Collection<? extends Goal>)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case ModelPackage.GOAL__DECOMPOSITION:
				getDecomposition().clear();
				return;
			case ModelPackage.GOAL__PRECEDENCE:
				getPrecedence().clear();
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case ModelPackage.GOAL__DECOMPOSITION:
				return decomposition != null && !decomposition.isEmpty();
			case ModelPackage.GOAL__PRECEDENCE:
				return precedence != null && !precedence.isEmpty();
		}
		return super.eIsSet(featureID);
	}

} //GoalImpl
